Micron Document
____ _ _ _ _
| _ \ ___ | |_ (_) _ __ ___ __| | (_) __ _
| |_) | / _ \ | __| | | | '_ \ / _ \ / _| | | | / _ |
| _ < | __/ | |_ | | | |_) | | __/ | (_| | | | | (_| |
|_| \_\ \___| \__| |_| | .__/ \___| \__,_| |_| \__,_|
|_|


The NomadNet German Wikipedia | Archives | Info
- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b- `b

πŸ” Search

Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―Β―

Namensparameter
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
top
Ein Namensparameter (englisch call by name) ist ein Parameter eines Unterprogramms in Programmiersprachen, der nicht bei seiner Übergabe, sondern erst bei seiner Benutzung, entsprechend der Signatur des Aktualparameters berechnet wird. Dies wurde vor allem in der Programmiersprache COBOL, daneben auch in ALGOL 60 genutzt, ist jedoch in modernen Sprachen unüblich.

Zur Einordnung: In Fortran gibt es ausschließlich Referenzparameter, in C und Java nur Wertparameter, in C++ gibt es beides. Namensparameter existieren – mit Ausnahme von PrΓ€prozessor-Makros in C und C++, deren Argumente Namensparameter sind – in keiner dieser Sprachen.

Namensparameter ermâglichen sowohl die Übergabe als auch Rückgabe von Werten.

Contents


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Ein einfaches Beispiel

A[1]Β := 10
A[2]Β := 20
iΒ := 1
xΒ := Funkt (A[i], i)
FUNCTION Funkt (a, i)Β : Real
iΒ := i+1
RETURN a
END

x wird der Wert 20 zugewiesen. Im Werteparameter-Fall wΓ€re x dagegen 10, ebenso bei Referenzparametern.

Ein angewandtes Beispiel in ALGOL 60

Als Beispiel soll die Simpsonsche NΓ€herungsformel zur Integralberechnung dienen. Ein FlΓ€chenintegral

y = f ( x ) {\displaystyle y=f(x)}
F = ∫ ∫ a b y d x {\displaystyle F=\int _{a}^{b}{ydx}}

kann in n Streifen der Breite h zerlegt werden. Dann lautet die hier verwendete NΓ€herung:

h = ( b βˆ’ βˆ’ a ) / n {\displaystyle h=(b-a)/n}
y i = f ( x i ) m i t x i = a + h β‹… β‹… i , i = 0 … … n {\displaystyle y_{i}=f(x_{i})\quad \quad mit\quad x_{i}=a+h\cdot i,\quad i=0\dots n}
F β‰ˆ β‰ˆ h 3 ( y 0 + y n + 4 ( y 1 + y 3 + β‹― β‹― y n βˆ’ βˆ’ 1 ) + 2 ( y 2 + y 4 + β‹― β‹― + y n βˆ’ βˆ’ 2 ) ) {\displaystyle F\approx {\frac {h}{3}}(y_{0}+y_{n}+4(y_{1}+y_{3}+\cdots y_{n-1})+2(y_{2}+y_{4}+\cdots +y_{n-2}))}

In Algol 60 wird dies folgendermaßen umgesetzt (das Beispiel ist nicht optimal, sondern eine mâglichst genaue Umsetzung der Definition):

1 'REAL' 'PROCEDURE' SIMPSON(A,B,F,X,N);
2 'REAL' A, B, X;
3 'INTEGER' N;
4 'REAL' 'PROCEDURE' F;
5 'BEGIN'
6 'INTEGER' I;
7 'REAL' H, S1, S2;
8 'ARRAY' Y[0:N];
9 HΒ := (B-A)/N;
10 'FOR' I:=0 'STEP' 1 'UNTIL' N 'DO'
11 'BEGIN'
12 X:=A+H*I;
13 Y[I]:=F;
14 'END';
15 S1Β := S2Β := 0;
16 'FOR' I:=1 'STEP' 2 'UNTIL' N-1 'DO' S1:=S1+Y[I];
17 'FOR' I:=2 'STEP' 2 'UNTIL' N-2 'DO' S2:=S2+Y[I];
18 SIMPSON:=H/3*(Y[0]+Y[N]+4*S1+2*S2);
19 'END'

Alle Parameter sind hier Namensparameter. Davon wird bei den Parametern X und F besonders Gebrauch gemacht (Zeilen 12 und 13). In Zeile 8 wird ein dynamisches Feld deklariert. Das Integral

y = ∫ ∫ 0 1 sin ⁑ ⁑ ( k ) d k {\displaystyle y=\int _{0}^{1}{\sin(k)}dk}

wird nΓ€herungsweise (n=20) berechnet mittels

Y:=SIMPSON(0,1,SIN(K),K,20);

Im Unterprogramm SIMPSON wird hier F durch SIN(K) und X durch K ersetzt.

Es sind auch Doppelintegrale mΓΆglich:

Das bestimmte Integral

z = ∫ ∫ 0 1 ∫ ∫ βˆ’ βˆ’ 1 1 e x 2 + y 2 d y d x {\displaystyle z=\int _{0}^{1}{\int _{-1}^{1}{e^{\sqrt {x^{2}+y^{2}}}dy}\,dx}}

kann nΓ€herungsweise mit

Z:=SIMPSON(0,1,SIMPSON(-1,1,EXP(SQRT(X 'POWER' 2+Y 'POWER' 2)),Y,20),X,20);

berechnet werden. Dies ist weder mit Referenzparametern, Wertparametern noch mit einfachen C-Makros in dieser Form realisierbar.